package com.googlecode.cannedbeans.generator.util;

import java.lang.annotation.Annotation;

/**
 * Allows the default and custom Hibernate Validator annotations.
 * @author Kim
 */
public class DefaultAnnotationFilterImpl implements AnnotationFilter{
    
    private static final String HIBERNATE_VALIDATOR_PACKAGE = "org.hibernate.validator";
    private static final Class HIBERNATE_VALIDATOR_CLASS = org.hibernate.validator.ValidatorClass.class;
    
    public boolean allow(Annotation annotation) {
        Class annotationType = annotation.annotationType();
        if (annotationType.getPackage().equals(HIBERNATE_VALIDATOR_PACKAGE)) {
            //Allow any of the default hibernate validator annotations.
            return true;
        } else if (annotationType.getAnnotation(HIBERNATE_VALIDATOR_CLASS)!=null) {
            //Allow all custom hibernate validator annotations. (Each custom hibernate validator annotation must have an @ValidatorClass declared).
            return true;
        }
        return false;
    }

}
